*** Replication materials for:
*** Daniel M. Smith, Alexandra Cirone, Dawn Teele, Gary W. Cox and Jon H. Fiva.
*** "Hidden Majoritarianism and Women's Career Progression in Proportional Representation Systems"
*** American Political Science Review

* set local directory as replication archive
*cd "XXXXXXXXX"

* create directories
*mkdir figures
*mkdir figures/gph
*mkdir tables
*mkdir estimates

** Data files needed: 
* DataSet_v28.dta -- Fiva and Smith Dataset  (https://www.jon.fiva.no/data/FivaSmith2024.zip)
* LCD_v13.dta -- Local Candidate Dataset (https://www.jon.fiva.no/data/FivaSorensenVollo2024.zip) 
* FivaHalseNatvik2023.dta -- Local Government Dataset (https://www.jon.fiva.no/data/FivaHalseNatvik2023.zip)
* Kommunevalg_1898_1967_fordelt.dta -- File from Norwegian Agency for Shared Services in Education and Research via email on August 22, 2022
* MP_education.dta -- Information about MP's education, hand-coded from biographies

** Stata packages needed:
* grc1leg (http://www.stata.com/users/vwiggins/)
* rdrobust (https://rdpackages.github.io/)
* eststo (http://www.stata-journal.com/software/sj7-2/)
* coefplot (https://github.com/benjann/coefplot)
* plotplain (http://www.stata-journal.com/software/sj17-3)

*******************************************************************************************
************ Figure 1: Share of women among cabinet members, list leaders,  ***************
************ members of parliament, local mayors, and local councilors ********************
*******************************************************************************************
do do/LocalNationalWomenOverTime.do /* Data preparation */
do do/Figure1.do /* Input: LocalNationalWomenOverTime */

*******************************************************************************************
************ Figure 2: Men's overrepresentation in majoritarian positions over time    ****
*******************************************************************************************
do do/Figure2 /* Input: LocalNationalWomenOverTime */

*******************************************************************************************
************ Figure 3: The differential effect of rank and becoming mayor on running ******
************ and winning in future national elections, 2003–2011 **************************
*******************************************************************************************
do do/Figure3 /* Input: LCD_v13.dta */
*** This file also produces the numerical results in Table A1 (Table_Fig3.tex)

*******************************************************************************************
************ Figure 4: MPs in the top list positions secure cabinet seats, women more *****
************ than men. ********************************************************************
*******************************************************************************************
do do/Figure4 /* Input: DataSet_v28 */
*** This file also produces the numerical results in Appendix Table A2 (Table_Fig4.tex)

*******************************************************************************************
************ Table 1: Conditional on Seniority, Women are as Likely to be Appointed to ****
************ Cabinet **********************************************************************
*******************************************************************************************
do do/Table1 /* Input: DataSet_v28 & MP_education */
*** This file also produces Appendix Table A3.

*******************************************************************************************
************ Appendix Figure A1: Mayors tend to come from the largest party and top rank ***
*******************************************************************************************
do do/FigureA1 /* Input: LCD_v13 */

*******************************************************************************************
************ Appendix Figure A2: Gender (im)balance on entering cohort, by party ***********
*******************************************************************************************
do do/FigureA2 /* Input: DataSet_v28 */

*******************************************************************************************
************ Appendix Figure A3: Do women and men MPs have different backgrounds? *********
*******************************************************************************************
do do/FigureA3 /* Input: DataSet_v28 & MP_education */

*******************************************************************************************
************ Appendix Figure A4: Difference in share of women in proportional positions ***
************ compared to the preceding majoritarian stepping stone ************************
*******************************************************************************************
do do/FigureA4 /* Input: LocalNationalWomenOverTime */

*******************************************************************************************
************ Appendix Figure A5: The differential effect of rank on running ***************
************ and winning in future national elections for lists without mayors ************
*******************************************************************************************
do do/FigureA5 /* Input: LCD_v13.dta */

*******************************************************************************************
************ Appendix Figure A6: Women mayors are more likely to get national list positions and win*
*******************************************************************************************
do do/FigureA6 /* Input: DataSet_v28 & LCD_v13 */

*******************************************************************************************
************ Appendix Figure A7: Do women debut in national politics at the same rate *****
************ and rank positions as men? ***************************************************
*******************************************************************************************
do do/FigureA7 /* Input: DataSet_v28 */

*******************************************************************************************
************ Figure A8: Do women and men progress equally in party list rankings? **********
*******************************************************************************************
do do/DataPrep.do /* Data preperation: DataSet_v28 --> DataPrep */
do do/FigureA8  /* Input: DataPrep */

*******************************************************************************************
************ Figure A9: Is there equal renomination of women and men MPs in winnable spots?*
*******************************************************************************************
do do/FigureA9 /* Input: DataSet_v28 */